package com.leetcode.p0;


import java.util.ArrayList;
import java.util.List;

public class Test78_2 {

    List<Integer>       t   = new ArrayList<>();
    List<List<Integer>> res = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {

        res.add(new ArrayList<>());

        dfs(0, nums);

        return res;
    }

    private void dfs(int start, int[] nums) {
        if (start >= nums.length)
            return;

        for (int i = start; i < nums.length; i++) {
            t.add(nums[i]);

            res.add(new ArrayList<>(t));
            dfs(i + 1, nums);
            t.remove(t.size() - 1);
        }
    }


    public static void main(String[] args) {
        Test78_2 test = new Test78_2();
        System.out.println(test.subsets(new int[]{1, 2, 3}));
//        System.out.println(test.subsets(new int[]{1, 2}));
    }

}
